import React, { Component } from 'react'

// 7. 导入 store 
import store from './store/index'

// console.log(store);
export default class Page1 extends Component {
    render() {


        // const state = store.getState()

        return (
            <div>
                {/* 8. 在组件中通过 store.getState() 来获取全局状态 */}
                <h1>Page1 ----- {store.getState().count} </h1>

                <button onClick={() => {
                    store.dispatch({
                        type: 'add'
                    })
                }}>全局状态 加1</button>

                <button onClick={() => {
                    store.dispatch({
                        type: 'reduce'
                    })
                }}>全局状态 减1</button>
                <button onClick={() => {
                    store.dispatch({
                        type: 'addNum',
                        payload: 8
                    })
                }}>全局状态 加8</button>
                <button onClick={() => {
                    store.dispatch({
                        type: 'reduceNum',
                        payload: 5
                    })
                }}>全局状态 减5</button>

            </div>
        )
    }
}
